<%@ WebHandler Language="C#" Class="Portlet1" %>

using System;
using System.Web;
using System.Threading;
using System.Text;
using System.Web.SessionState;
//using Nextel.BE;
//using Net.db;
using System.Collections.Generic;
using System.Collections;

public class  Portlet1 : IHttpHandler , IReadOnlySessionState {
    
    //live_data    
    //String operacion = "";
    //String fechainicio = "";
    //String fechafin = "";
    StringBuilder sb = new StringBuilder();
    //String ValBarX = "";
    //String ValBarY = "";
    //String ValBarTit = "";
    
    public void ProcessRequest (HttpContext context) {
       context.Response.ContentType = "text/plain";

       //List<BEPedido> lista = null;
       
       String inicio = context.Request["inicio"];

       if (inicio != "0")
       {

           //fechainicio = Utils.getStringFechaYYMMDDHHMM(context.Request["fechainicio"]) + " 00:00:00";
           //fechafin = Utils.getStringFechaYYMMDDHHMM(context.Request["fechafin"]) + " 23:59:00";
           //operacion = context.Request["operacion"];


           //lista = DBNet.getVentTotales(operacion, fechainicio, fechafin);

           //if (lista.Count != 0)
           //{
           //    ValBarY = IdiomaCultura.getMensajeEncodeHTML(IdiomaCultura.WEB_MONTO);
           //    ValBarTit = IdiomaCultura.getMensajeEncodeHTML(IdiomaCultura.WEB_VENTAS_TOTALES);
           //    sb = getGrafico(lista, ValBarY, ValBarTit);
           //}
           //else { sb = getGraficoDefault(); } 

       }
       else
       {
           sb = getGraficoDefault();
       }
        
        
        
       context.Response.Write(sb.ToString()); 
    }


    //public StringBuilder getGrafico(List<BEPedido> lista, String valBarY, String valBarTit) 
    //{
        //if (lista != null && lista.Count > 0)
        //{
        //    Int64 i = 0;
        //    ValBarX = lista.Count < 18 ? IdiomaCultura.getMensajeEncodeHTML(IdiomaCultura.WEB_DIAS) : IdiomaCultura.getMensajeEncodeHTML(IdiomaCultura.WEB_MESES);
             
        //    String var1 = "<graph caption='"+ valBarTit +"'  xAxisName='"+ValBarX+"' yAxisMinValue='15000' yAxisName='" + valBarY + "' decimalPrecision='0' formatNumberScale='0' numberPrefix='$' showNames='1' canvasBorderColor='FFFFFF' showValues='0' showAlternateHGridColor='1' AlternateHGridColor='ff5904' divLineColor='ff5904' canvasBorderColor='666666' divLineAlpha='20' alternateHGridAlpha='30'>";
            

        //    foreach (BEPedido bean in lista)
        //    {

        //        string var = i == 0 ? var1 : "/>";
        //        string varF = i == lista.Count - 1 ? "/></graph>" : "";               
 
        //        sb.Append(String.Format(var + "{0} {1} {2}" + varF,

        //         "<set name='" + HttpUtility.HtmlEncode(lista.Count < 18 ? bean.fecha.Substring(6, 2) : bean.fecha.Substring(4, 2)) + "'",                
        //         "value='" + HttpUtility.HtmlEncode(bean.monto) + "'",
        //         "hoverText='" + HttpUtility.HtmlEncode(bean.fecha) + "'"
                
        //        ));

        //        i++;
        //    }
        //}
    //    return sb;
        
    //}

    public StringBuilder getGraficoDefault()
    {
        sb.Append("<graph caption='Resumen'  xAxisName='Month' yAxisMinValue='15000' yAxisName='Price' decimalPrecision='0' formatNumberScale='0' numberPrefix='$' showNames='1' canvasBorderColor='FFFFFF' showValues='0' showAlternateHGridColor='1' AlternateHGridColor='ff5904' divLineColor='ff5904' canvasBorderColor='666666' divLineAlpha='20' alternateHGridAlpha='30'>");
        sb.Append("  <set name='10' value='10' hoverText='10112010' /> ");
        sb.Append("  <set name='02' value='50' hoverText='02122010' /> ");
        sb.Append("  <set name='07' value='40' hoverText='07122010' /> ");
        sb.Append("  </graph> ");
 

        return sb;
        
    }
    
    public bool IsReusable {
        get {
            return false;
        }
    }

    private int RandomNumber(int min, int max)
    {
        Random random = new Random();
        return random.Next(min, max);
    }

}